package jzqb.dao.impl;

import cnki.tpi.kbatis.sqlsession.SqlSession;
import cnki.tpi.kbatis.utils.DataSourceUtil;
import jzqb.bo.StandardBo;
import jzqb.bo.SubscriptBo;
import jzqb.bo.SubscriptDataBo;
import jzqb.dao.SubscriptDataDao;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 自用库数据层实现类
 */
@Repository
public class SubscriptDataDaoImpl implements SubscriptDataDao {
    @Override
    public Boolean insertSubscriptData(SubscriptDataBo subscriptDataBo) {
        SqlSession sqlSession = DataSourceUtil.getSqlSession();
        String statementId = "jzqb.dao.SubscriptDataDao.insertSubscriptData";
        return sqlSession.executeInsert(statementId, subscriptDataBo);
    }

    @Override
    public SubscriptDataBo getSubscriptDataByCondition(SubscriptDataBo subscriptDataBo) {
        SqlSession sqlSession = DataSourceUtil.getSqlSession();
        String statementId = "jzqb.dao.SubscriptDataDao.getSubscriptDataByCondition";
        return sqlSession.selectOne(statementId, subscriptDataBo, false);
    }

    @Override
    public List<SubscriptDataBo> getReadSubscriptData(SubscriptDataBo subscriptDataBo) {
        SqlSession sqlSession = DataSourceUtil.getSqlSession();
        String statementId = "jzqb.dao.SubscriptDataDao.getReadSubscriptData";
        return sqlSession.selectList(statementId, subscriptDataBo, false);
    }

    @Override
    public Long getReadSubscriptDataCount(SubscriptDataBo subscriptDataBo) {
        SqlSession sqlSession = DataSourceUtil.getSqlSession();
        String statementId = "jzqb.dao.SubscriptDataDao.getReadSubscriptDataCount";
        return sqlSession.getCount(statementId, subscriptDataBo);
    }

    @Override
    public List<StandardBo> getNewData(SubscriptDataBo subscriptDataBo) {
        SqlSession sqlSession = DataSourceUtil.getSqlSession();
        String statementId = "jzqb.dao.SubscriptDataDao.getNewData";
        return sqlSession.selectList(statementId, subscriptDataBo, false);
    }

    @Override
    public List<SubscriptDataBo> getNotBelongToData(SubscriptDataBo subscriptDataBo) {
        SqlSession sqlSession = DataSourceUtil.getSqlSession();
        String statementId = "jzqb.dao.SubscriptDataDao.getNotBelongToData";
        return sqlSession.selectList(statementId, subscriptDataBo, false);
    }

    @Override
    public Long getNotBelongToDataCount(SubscriptDataBo subscriptDataBo) {
        SqlSession sqlSession = DataSourceUtil.getSqlSession();
        String statementId = "jzqb.dao.SubscriptDataDao.getNotBelongToDataCount";
        return sqlSession.getCount(statementId, subscriptDataBo);
    }

    @Override
    public List<StandardBo> getNotReadDataList(SubscriptDataBo subscriptDataBo) {
        SqlSession sqlSession = DataSourceUtil.getSqlSession();
        String statementId = "jzqb.dao.SubscriptDataDao.getNotReadDataList";
        return sqlSession.selectList(statementId, subscriptDataBo,false);
    }

    @Override
    public List<String> getReadIdList(SubscriptDataBo subscriptDataBo) {
        SqlSession sqlSession = DataSourceUtil.getSqlSession();
        String statementId = "jzqb.dao.SubscriptDataDao.getReadIdList";
        return sqlSession.selectList(statementId, subscriptDataBo,false);
    }

    @Override
    public List<StandardBo> getFinalResult(SubscriptDataBo subscriptDataBo) {
        SqlSession sqlSession = DataSourceUtil.getSqlSession();
        String statementId = "jzqb.dao.SubscriptDataDao.getFinalResult";
        return sqlSession.selectList(statementId, subscriptDataBo,false);
    }

    @Override
    public Long getFinalResultCount(SubscriptDataBo subscriptDataBo) {
        SqlSession sqlSession = DataSourceUtil.getSqlSession();
        String statementId = "jzqb.dao.SubscriptDataDao.getFinalResultCount";
        return sqlSession.getCount(statementId, subscriptDataBo);
    }

    @Override
    public Boolean deleteAllsubscriptData(SubscriptBo subscriptBo) {
        SqlSession sqlSession = DataSourceUtil.getSqlSession();
        String statementId = "jzqb.dao.SubscriptDataDao.deleteAllsubscriptData";
        return sqlSession.executeDelete(statementId, subscriptBo);
    }
}
